package com.bulk.demo.scheduled;

import lombok.SneakyThrows;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.util.concurrent.TimeUnit;

/**
 * 定时任务测试
 *
 * @author 散装java
 * @since 2022/6/6
 */
@Component
public class ScheduledTest {


    @SneakyThrows
//    @Scheduled(cron = "0/2 * * * * ? ")
    public void task1() {
        System.out.println(Thread.currentThread().getName() + "  ===> task1 ==" + LocalDateTime.now());
        TimeUnit.HOURS.sleep(1);
    }

//    @Scheduled(cron = "0/1 * * * * ? ")
    public void task2() {
        System.out.println(Thread.currentThread().getName() + "  ===> task2 ==" + LocalDateTime.now());
    }
}
